home *** CD-ROM | disk | FTP | other *** search
/ PC Format (UK) 134 / PC Format DVD 2002.iso / Full / 3D Flash Animator / 3DFlashAnimator3Setup.exe / file0782_1eeeab_1ef2b1.bin < prev    next >
Encoding:
Text File  |  2001-11-08  |  3.4 KB  |  130 lines

  1. <title>New Cylinder</title>
  2.  
  3. <script language="EasyScript">
  4.  
  5. registry = "New\\Model\\Cylinder";
  6.  
  7. /////////////////
  8. function OnLoad ()
  9. {
  10.     length_x = getRegistryValue (registry, "length_x", 100);
  11.     length_y = getRegistryValue (registry, "length_y", 100);
  12.     length_z = getRegistryValue (registry, "length_z", 100);
  13.  
  14.     div_p = getRegistryValue (registry, "div_p", 10);
  15.  
  16.     model = new Model;
  17.     model.setName ("Cylinder");
  18. }
  19. //////////////////////
  20. function CreateModel ()
  21. {
  22.     if (div_p < 1) div_p = 1;
  23.     
  24.     ip = 1 / div_p;
  25.     
  26.     array0 = new Array;
  27.     array1 = new Array;
  28.     array2 = new Array;
  29.     array3 = new Array;
  30.  
  31.     for (p=1; p>ip/2-1; p-=ip){
  32.         vertex = new Vertex3D;
  33.         vertex.x = length_x * sin(p*pi) / 2;
  34.         vertex.y = length_y / 2;
  35.         vertex.z = length_z * cos(p*pi) / 2;
  36.         index = model.addVertex (vertex);
  37.         array0.add (index);
  38.         vertex = new Vertex3D;
  39.         vertex.x = length_x * sin(p*pi) / 2;
  40.         vertex.y = length_y / 2;
  41.         vertex.z = length_z * cos(p*pi) / 2;
  42.         index = model.addVertex (vertex);
  43.         array1.add (index);}
  44.  
  45.     for (p=-1; p<1-ip/2; p+=ip){
  46.         vertex = new Vertex3D;
  47.         vertex.x = length_x * sin(p*pi) / 2;
  48.         vertex.y = -length_y / 2;
  49.         vertex.z = length_z * cos(p*pi) / 2;
  50.         index = model.addVertex (vertex);
  51.         array2.add (index);
  52.         vertex = new Vertex3D;
  53.         vertex.x = length_x * sin(p*pi) / 2;
  54.         vertex.y = -length_y / 2;
  55.         vertex.z = length_z * cos(p*pi) / 2;
  56.         index = model.addVertex (vertex);
  57.         array3.add (index);}
  58.  
  59.     model.addPolygon (array0);
  60.     model.addPolygon (array3);
  61.  
  62.     for (v=1; v< array1.count-1; v++){
  63.         model.addPolygon (array1[array1.count-v],array1[array1.count-v-1],array2[v+1],array2[v]);}
  64.  
  65.     model.addPolygon (array1[1], array1[0], array2[0], array2[array1.count-1]);
  66.     model.addPolygon (array1[0], array1[array1.count-1], array2[1], array2[0]);
  67.  
  68.     for (i=0; i< model.polygons.count; i++){
  69.         if (i < 2) model.polygons[i].smooth = false;
  70.         model.polygons[i].face = 1;}
  71.  
  72.     model.applyTexture ("cylindrical", 'Y');
  73.  
  74.     setRegistryValue (registry, "length_x", length_x);
  75.     setRegistryValue (registry, "length_y", length_y);
  76.     setRegistryValue (registry, "length_z", length_z);
  77.  
  78.     setRegistryValue (registry, "div_p", div_p);
  79.  
  80.     window.returnValue (model);
  81.     window.close ();
  82. }
  83.  
  84. </script>
  85.  
  86. <body bgcolor="normal" text="#000000" OnLoad="OnLoad()" translate>
  87. <div valign=middle>
  88.  
  89. <table width="100%" cellspacing=4 cellpadding=0 bgcolor="light" borderstyle="raised">
  90. <tr><td valign=top><img src="images/large_model.bitmap">
  91. <td><table>
  92. <tr><td>
  93. <font size=5>Cylinder</font>
  94. <td><input type="text" size=16 name="model.name">
  95. </table></table>
  96.  
  97. <spacer height=4>
  98.  
  99. <table width=100% cellspacing=4 cellpadding=4 bgcolor="light" borderstyle="raised">
  100.     <tr><td>
  101.         <table>
  102.             <font size=1>
  103.             <tr><td></td><td align=center>X</td><td align=center>Y</td><td align=center>Z</td></tr>
  104.             </font>
  105.             <tr>
  106.             <td>Length
  107.             <td><input type=text name="length_x" size=5>
  108.             <td><input type=text name="length_y" size=5>
  109.             <td><input type=text name="length_z" size=5>
  110.             </tr>
  111.         </table>
  112.     <tr><td>
  113.         <table>
  114.             <tr>
  115.             <td>Divisions
  116.             <td><input type=text name="div_p" size=4>
  117.         </table>
  118.  
  119. </table>
  120.  
  121. <spacer height=8>
  122.  
  123. <table cellspacing=0 cellpadding=0 width="100%">
  124. <tr><td align=right>
  125. <a button onMouseUp="CreateModel()" width=+16 height=+3><img src="images/small_model.bitmap" hspace=4>Create cylinder</a>
  126. <a button onMouseUp="window.close()" width=+32 height=+3>Cancel</a>
  127. </table>
  128.  
  129. <spacer height=4>
  130.